home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / docs / x3mdmo01 / plasma.txt < prev    next >
Text File  |  1994-12-13  |  5KB  |  113 lines

  1.  
  2.  ████       ████▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  3.  ▀███▄     ▄███▀            -= Demo Programming Series =-
  4.    ▀███▄ ▄███▀                  by Sten Roger Sandvik
  5.      ▀█████▀
  6.     ▄███▀███▄              I - HOW TO CREATE PLASMA EFFECTS
  7.   ▄███▀   ▀███▄
  8.  ████       ████             (c) 1994 by X3M Productions
  9.  ████       ████▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  10.  
  11.  
  12.   Hey all out there, and welcome to part one of the X3M demo programming
  13.   series. In this and all of the following demo programming series, I'll
  14.   take it for granted that you know how to program the VGA controller,
  15.   and some knowledge about X-mode.
  16.  
  17.   This time we'll discuss a psychadelic effect that is used in many demos.
  18.   Yepp! You got it... Plasmas! Oki, no sence in wasting time here talking
  19.   about bullshit... let's go to work!
  20.  
  21.  
  22.    The Workings of Plasmas
  23.  
  24.     In this text I will only cover the real type of plasma. No sills here,
  25.     only state-of-the-art realtime plasma calculations!
  26.  
  27.     When you look at the method realtime plasmas is created, you'll see that
  28.     it's merely an intersection of a number of cosinus waves. In this example
  29.     we'll use 4 cosinus waves, which makes a very cool effect. The color of
  30.     a particular point is calculated using this formula:
  31.  
  32.         color = costbl[cos_1]+costbl[cos_2]+costbl[cos_3]+costbl[cos_4]
  33.  
  34.     The trick is getting the four indexes of that cosinus table to create
  35.     something that looks neat. We use two of the indexes for vertical
  36.     movement, and the remaining two for horizontal movement.
  37.  
  38.     This means that by changing these valuse we can move along the plasma.
  39.     To draw an individual screen, we pass the values of the four to another
  40.     four so that we do not disturb the original values. For every pixel on
  41.     the x-axis, we add values to the first two indexes, then displaying the
  42.     next pixel. For every row down, we add values to the second two indexes.
  43.  
  44.     By altering the original four values, we can get all sorts of neat
  45.     movement and cycling of the plasma. The reason we use a cosinus function
  46.     is as follows:
  47.  
  48.         - Nice curvature.
  49.         - Adding two or more together it's posible to get circular
  50.           pictures.
  51.  
  52.  
  53.  Fading
  54.  
  55.     When you look at the sample demo, you'll see that when it fades in and out
  56.     the colors all reach their destination at the same time. This is wery
  57.     clever, if I may say so ? Well, in other words, they do not all increment
  58.     by one until they hit the right color. If you should do it this way the
  59.     fading looks extremely unproffesional.
  60.  
  61.  
  62.  How to do a step-crossfade
  63.  
  64.     Each red, green and blue values can be between 0 and 63. Have the palette
  65.     we want to get to in TOPAL and the temporary palette in TEMPPAL. For each
  66.     step, from 0 to 63 do the following:
  67.  
  68.         TEMPPAL[loop].red   = TOPAL[loop].red   * step / 64;
  69.         TEMPPAL[loop].green = TOPAL[loop].green * step / 64;
  70.         TEMPPAL[loop].blue  = TOPAL[loop].blue  * step / 64;
  71.  
  72.     That means if we are halfway through the crossfade (step=32) and the red
  73.     value is meant to get to 16, then naturally the color would be value
  74.     would be 8, which is half the way. This means all colors will fade in/out
  75.     with the same ratios.
  76.  
  77.  
  78.  Palette rotating
  79.  
  80.     The palette rotating is very simple, so here is a brief description on
  81.     how to do it.
  82.  
  83.         - Move color 0 into a temporary variable.
  84.         - Move color 1 into color 0
  85.         - Move color 2 into color 1
  86.           .
  87.           .
  88.         - Move color 255 into color 254
  89.         - Move temporary color into color 255
  90.  
  91.  
  92.  About the sample demo
  93.  
  94.     The plasma sample demo code is written in pascal, and is (I think) self
  95.     explanitory. I have also done an assembly version that you can look at,
  96.     but the pascal code illustrates the plasma principle very clearly.
  97.  
  98.     Well if you have any questions about anything (Uhh... well about
  99.     programming), just leave me a note. Be seein' YA!
  100.  
  101.                                                  E-mail -> srs@alkymi.unit.no
  102.  
  103.  
  104.  ZIP file contents:
  105.  
  106.     PLASMA.TXT          - The file you are looking at NOW!
  107.     PLASMA.PAS          - Pascal version of the sample code
  108.     PLASMA.EXE          - Executable version of the pascal version (Huh ?)
  109.     COSTBL.INC          - Cosinus table file for the assembler version
  110.     PLASMEFF.ASM        - Assembler version of the sample code (FAST!)
  111.     PLASMEFF.EXE        - Executable version of the assembler version!
  112.  
  113.